/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

	PrintSample

		PrintSample.h

			Definitions of data types, constant values, and functions
			used in the PrintSample application.

 ------------------------------------------------------------------

 Copyright (c) 2010 Microsoft Corporation. All rights reserved.

 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
 ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
 PARTICULAR PURPOSE.

 ------------------------------------------------------------------
*/
#pragma once

#include "resource.h"

#define PRINT_SAMPLE_HEAP_FLAGS	((DWORD)HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY)

#define MAIN_WINDOW_FONT_SIZE	((int)20)

// Application specific data structures
//  that describe the document content

#define			MAXIMUM_TEXT_FIELD_LENGTH		1024

typedef struct tagPageText {
	XPS_POINT	textOrigin;
	FLOAT		fontSize;
	XPS_STYLE_SIMULATION	textStyle;
	WCHAR		text[MAXIMUM_TEXT_FIELD_LENGTH];
} PAGETEXT, *PPAGETEXT;

typedef struct tagPageContent {
	DWORD		pageNumber;
	XPS_SIZE	pageSize;
	DWORD		pageTextItems;
	PPAGETEXT	pageTextArray;
} PAGECONTENT, *PPAGECONTENT;

typedef struct tagDocumentContent {
	DWORD			pages;
	PPAGECONTENT	pageContentArray;
} DOCUMENTCONTENT, *PDOCUMENTCONTENT;

typedef struct tagPrintThreadInfo {
	//
	// Application related data
	HINSTANCE			applicationInstance;
	HWND				parentWindow;
	HFONT				windowFont;
	HCURSOR				waitCursor;
	HCURSOR				normalCursor;
	//
	// Printing thread related data
	HANDLE				quitEvent;
	HANDLE				printThreadHandle;
	DWORD				printThreadId;
	//
	// Document data
	PDOCUMENTCONTENT	documentContent;
	DWORD				currentPage;
	//
	// Print job data
	HANDLE				completionEvent;
	LPDEVMODE			devmode;
	LPWSTR				printerName;
	DWORD				packages;
	DWORD				currentPackage;
	DWORD				copies;
	DWORD				currentCopy;
	IXpsPrintJob		*printJob;
	IXpsPrintJobStream	*printJobStream;
	IXpsOMObjectFactory *xpsFactory;
	IXpsOMPackageWriter *packageWriter;
	IXpsOMFontResource	*fontResource;
} PRINTTHREADINFO, *PPRINTTHREADINFO;


// Application specific window messages
#define USER_PRINT_SELECT_PRINTER	(WM_USER	+ 1)
#define USER_PRINT_SELECT_FILE		(WM_USER	+ 2)
#define USER_PRINT_START_PRINTING	(WM_USER	+ 3)
#define USER_PRINT_STATUS_UPDATE	(WM_USER	+ 4)
#define USER_PRINT_CLOSING			(WM_USER	+ 5)
#define USER_PRINT_COMPLETE			(WM_USER	+ 6)
#define USER_CREATE_DOCUMENT		(WM_USER	+ 7)
#define USER_DESTROY_DOCUMENT		(WM_USER	+ 8)

// Other constant values
#define MAXIMUM_RESOURCE_STRING_LENGTH 256

#define SHORT_WAIT					10
#define THREAD_START_WAIT			(SHORT_WAIT * 50)
#define THREAD_END_WAIT				10000
#define LONG_WAIT					60000

//
// Forward function declarations

// MainWindow.cpp
LRESULT CALLBACK	WndProc				(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

// PrintThread.cpp
DWORD WINAPI		PrintThreadProc		(LPVOID);

// DocumentFunctions.cpp
HRESULT CreateTestDocumentContent		(PPRINTTHREADINFO threadInfo, DWORD numPages);
HRESULT DeleteDocumentContent			(PPRINTTHREADINFO threadInfo);

// UtilityFunctions.cpp
int		MessageBoxWithResourceString	(HINSTANCE, HWND, int, int, UINT);
int		GetAllocedResourceString		(HINSTANCE, int, LPWSTR *);

// dialog box procedures
INT_PTR CALLBACK	AboutDlgProc		(HWND, UINT, WPARAM, LPARAM); // aboutdlg.cpp
INT_PTR CALLBACK	PrintDlgProc		(HWND, UINT, WPARAM, LPARAM); // printdlg.cpp
INT_PTR CALLBACK	NewDocumentDlgProc	(HWND, UINT, WPARAM, LPARAM); // newdocumentdlg.cpp
